package com.atguigu.ssm.controller;

import com.atguigu.ssm.bean.User;
import com.atguigu.ssm.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

/**
 * Date:2020/10/9
 * Author:ybc
 * Description:
 */
@Controller
public class UserController {

    @Autowired
    private UserService userService;

    /*@RequestMapping("/users")
    public String getUserList(Map<String, Object> map){
        List<User> list = userService.getUserList();
        map.put("list", list);
        return "list";
    }*/

    @RequestMapping("/users/{pageNumStr}")
    public String getPageUser(@PathVariable("pageNumStr") String pageNumStr, Map<String, Object> map){
        Integer pageNum = 1;
        try {
            pageNum = Integer.parseInt(pageNumStr);
        } catch (NumberFormatException e) {}
        PageInfo<User> page = userService.getPageUser(pageNum);
        System.out.println(page);
        map.put("page", page);
        return "list";
    }


}
